package com.huawei.hwid.core.d.c;

import com.huawei.hwid.core.d.b.e;
import java.lang.reflect.InvocationTargetException;

public class c implements a {
    private static c a;

    public static synchronized c b() {
        c cVar;
        synchronized (c.class) {
            if (a == null) {
                a = new c();
            }
            cVar = a;
        }
        return cVar;
    }

    public static Object c() {
        Object obj = null;
        try {
            Class cls = Class.forName("android.telephony.MSimTelephonyManager");
            obj = cls.getDeclaredMethod("getDefault", new Class[0]).invoke(cls, new Object[0]);
        } catch (RuntimeException e) {
            e.a("MutiCardHwImpl", " getDefaultMSimTelephonyManager wrong RuntimeException", true);
        } catch (Exception e2) {
            e.a("MutiCardHwImpl", " getDefaultMSimTelephonyManager wrong ", true);
        }
        return obj;
    }

    public int a() {
        try {
            Object c = c();
            if (c != null) {
                return ((Integer) c.getClass().getMethod("getDefaultSubscription", new Class[0]).invoke(c, new Object[0])).intValue();
            }
            return 0;
        } catch (NoSuchMethodException e) {
            e.d("MutiCardHwImpl", " NoSuchMethodException wrong ", true);
            return -1;
        } catch (IllegalArgumentException e2) {
            e.d("MutiCardHwImpl", " IllegalArgumentException wrong ", true);
            return -1;
        } catch (InvocationTargetException e3) {
            e.d("MutiCardHwImpl", " InvocationTargetException wrong ", true);
            return -1;
        } catch (RuntimeException e4) {
            e.d("MutiCardHwImpl", " RuntimeException wrong ", true);
            return -1;
        } catch (Exception e5) {
            e.d("MutiCardHwImpl", " Exception wrong ", true);
            return -1;
        }
    }

    public int a(int i) {
        int i2;
        if (i == -1) {
            i2 = 5;
        } else {
            i2 = 0;
        }
        Class[] clsArr = new Class[]{Integer.TYPE};
        Object[] objArr = new Object[]{Integer.valueOf(i)};
        try {
            Object c = c();
            if (c != null) {
                i2 = ((Integer) c.getClass().getDeclaredMethod("getSimState", clsArr).invoke(c, objArr)).intValue();
            }
        } catch (IllegalAccessException e) {
            e.d("MutiCardHwImpl", " IllegalAccessException wrong ", true);
        } catch (NoSuchMethodException e2) {
            e.d("MutiCardHwImpl", " NoSuchMethodException wrong ", true);
        } catch (IllegalArgumentException e3) {
            e.d("MutiCardHwImpl", " IllegalArgumentException wrong ", true);
        } catch (RuntimeException e4) {
            e.d("MutiCardHwImpl", " getSimState wrong RuntimeException", true);
        } catch (Exception e5) {
            e.d("MutiCardHwImpl", " getSimState wrong ", true);
        }
        return i2;
    }
}
